package org.zhadoop.stream.cql.semanticanalyzer.parser.context;

import org.zhadoop.stream.cql.exception.SemanticAnalyzerException;
import org.zhadoop.stream.cql.semanticanalyzer.CreateInputStreamAnalyzer;
import org.zhadoop.stream.cql.semanticanalyzer.SemanticAnalyzer;
import org.zhadoop.stream.cql.semanticanalyzer.parsecontextwalker.ParseContextWalker;

/**
 * 创建输入流语法解析内容
 * 
 * @author zwd
 *
 */
public class CreateInputStatementContext extends CreateStreamStatementContext {

	private ClassNameContext deserClassName;

	private StreamPropertiesContext deserProperties;

	private ClassNameContext sourceClassName;

	private StreamPropertiesContext sourceProperties;

	private ParallelClauseContext parallelNumber;

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append("CREATE INPUT STREAM ");
		sb.append(getStreamName());
		sb.append(" " + getColumns().toString());
		if (deserClassName != null) {
			sb.append(" SERDE " + deserClassName.toString());
		}
		if (deserProperties != null) {
			sb.append(" " + deserProperties.toString());
		}
		sb.append(" SOURCE " + sourceClassName.toString());
		if (sourceProperties != null) {
			sb.append(" " + sourceProperties.toString());
		}

		if (parallelNumber != null) {
			sb.append(" " + parallelNumber.toString());
		}

		return sb.toString();
	}
	
	@Override
	public SemanticAnalyzer createAnalyzer() throws SemanticAnalyzerException {
		return new CreateInputStreamAnalyzer(this);
	}
	

	public ClassNameContext getDeserClassName() {
		return deserClassName;
	}

	public void setDeserClassName(ClassNameContext deserClassName) {
		this.deserClassName = deserClassName;
	}

	public StreamPropertiesContext getDeserProperties() {
		return deserProperties;
	}

	public void setDeserProperties(StreamPropertiesContext deserProperties) {
		this.deserProperties = deserProperties;
	}

	public ClassNameContext getSourceClassName() {
		return sourceClassName;
	}

	public void setSourceClassName(ClassNameContext sourceClassName) {
		this.sourceClassName = sourceClassName;
	}

	public StreamPropertiesContext getSourceProperties() {
		return sourceProperties;
	}

	public void setSourceProperties(StreamPropertiesContext sourceProperties) {
		this.sourceProperties = sourceProperties;
	}

	public ParallelClauseContext getParallelNumber() {
		return parallelNumber;
	}

	public void setParallelNumber(ParallelClauseContext parallelNumber) {
		this.parallelNumber = parallelNumber;
	}

	@Override
	protected void walkChild(ParseContextWalker walker) {
		super.walkChild(walker);
		walkExpression(walker, deserProperties);
		walkExpression(walker, parallelNumber);
		walkExpression(walker, sourceProperties);
	}

	

}
